package com.lsj.firsterp.service.impl;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.lsj.firsterp.mapper.UserMapper;
import com.lsj.firsterp.model.User;
import com.lsj.firsterp.service.UserService;

import java.util.List;

/**
 * @author Lsj
 * @version 1.0
 * @date 2021/7/1 17:58
 */

@Service
@AllArgsConstructor
public class UserServiceImpl implements UserService {


    private UserMapper userMapper;


    /**
     * delete by primary key
     * 根据主键删除
     *
     * @param id primaryKey
     * @return deleteCount
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    /**
     * insert record to table selective
     * 插入数据
     *
     * @param record the record
     * @return insert count
     */
    @Override
    public int insertSelective(User record) {
        return userMapper.insertSelective(record);
    }

    /**
     * select by primary key
     * 查看
     *
     * @param id primary key
     * @return object by primary key
     */
    @Override
    public User selectByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    /**
     * update record selective
     * 更新
     *
     * @param record the updated record
     * @return update count
     */
    @Override
    public int updateByPrimaryKeySelective(User record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 查询全部
     *
     * @param user 用户
     * @return 用户类型为list
     */
    @Override
    public List<User> selectByAll(User user) {
        return userMapper.selectByAll(user);
    }

    /**
     * 登录
     *
     * @param user 用户
     * @return 成功或者失败
     */
    @Override
    public User login(User user) {
        return userMapper.login(user);
    }
}

